<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\library\token\driver\Redis;
use think\Db;

/**
 * 对外接口
 */
class Foreign extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 获取商品库存成本
     *
     */
    public function getstock(){
        $params = input('');
        $number = isset($params['number'])?$params['number']:'';
        $goods = Db::name('goods')->where(array('number'=>$number))->find();
        if(empty($goods)){
            $this->error('商品不存在');
        }
        $list = Db::name('goods_house_stock')
            ->field('g.balance,g.stock,s.name')
            ->alias('g')
            ->where(array('goods_id'=>$goods['id']))
            ->join('storehouse s','g.storehouse_id = s.id')
            ->select();
        $this->success('请求成功',$list);
    }

}
